package org.musicguardian.core.model;

import java.io.Serializable;
import java.util.HashMap;

public class RemoteLink implements Serializable, Comparable<RemoteLink> {
    private Integer weight;

    private Artist localArtist;

    private Artist remoteArtist;

    public RemoteLink() {
	super();
    }

    public RemoteLink(Integer weight, Artist localArtist, Artist remoteArtist) {
	super();
	this.weight = weight;
	this.localArtist = localArtist;
	this.remoteArtist = remoteArtist;
    }

    public Artist getLocalArtist() {
        return localArtist;
    }

    public Artist getRemoteArtist() {
        return remoteArtist;
    }

    public Integer getWeight() {
	return weight;
    }

    public int compareTo(RemoteLink link) {
	return weight.compareTo(link.getWeight());
    }

    @Override
    public int hashCode() {
	final int PRIME = 31;
	int result = 1;
	result = PRIME * result + ((localArtist == null) ? 0 : localArtist.hashCode());
	result = PRIME * result + ((remoteArtist == null) ? 0 : remoteArtist.hashCode());
	result = PRIME * result + ((weight == null) ? 0 : weight.hashCode());
	return result;
    }

    @Override
    public boolean equals(Object obj) {
	if (this == obj)
	    return true;
	if (obj == null)
	    return false;
	if (getClass() != obj.getClass())
	    return false;
	final RemoteLink other = (RemoteLink) obj;
	if (localArtist == null) {
	    if (other.localArtist != null)
		return false;
	} else if (!localArtist.equals(other.localArtist))
	    return false;
	if (remoteArtist == null) {
	    if (other.remoteArtist != null)
		return false;
	} else if (!remoteArtist.equals(other.remoteArtist))
	    return false;
	if (weight == null) {
	    if (other.weight != null)
		return false;
	} else if (!weight.equals(other.weight))
	    return false;
	return true;
    }
}
